const Router = require('@koa/router');

const { auth } = require('@middleware/auth.middleware');

const { changePageType } = require('@middleware/tools.middleware');

const { validator, validatorById } = require('./cart.middleware');

const { add, list, update, remove, bulkUpdate } = require('./cart.controller');

const router = new Router({ prefix: '/cart' });

router.use(auth);

// 上传
router.post('/add', add);

router.get('/list', changePageType, list);

router.patch('/update', validator, update);

router.delete('/delete/:id', remove);

router.post('/bulkUpdate', validatorById, bulkUpdate);

module.exports = router;
